package com.lemote.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 
 * @author wuhui
 * @time 2011-7-16 上午11:29:26
 * @Version:0.0.1
 * @since smt
 */
@Entity
@Table(name="smt_circuitBoard")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class CircuitBoard extends IdEntity {

	/**
	 * fail报告
	 */
	private List<FailReoprt> fails;
	
	private FlowTask flowTask;
	
	/**
	 * 上一个站点
	 */
	private FlowTask preTask;
	/**
	 * 板子编号
	 */
	private String icNo;
	
	/**
	 * 录入MAC时间
	 */
	private Date macDate;
	
	/**
	 * MAC地址
	 */
	private String macNo;
	
	private User macUser;
	
	/**
	 * 订单
	 */
	private OrderEntity orderEntity;
	
	private String orderNo;
	
	/**
	 * pmon版本号
	 */
	private String pmonVersion;
	
	/**
	 * 程序版本
	 */
	private String programVersion;
	
	/**
	 * 操作记录
	 */
	private List<OperationRecord> records;
	
	/**
	 * 备注，报废时必须
	 */
	private String remark;
	
	/**
	 * 维修报告
	 */
	private List<RepairReport> repairs;
	
	/**
	 * 状态 0：正常，1：不良，2：报废
	 */
	private String status;
	
	/**
	 * 系统名称
	 */
	private String systemName;
	
	/**
	 * 系统版本
	 */
	private String systemVersion;
	
	@OneToMany(mappedBy = "board", cascade = { CascadeType.ALL}, fetch = FetchType.LAZY, targetEntity = FailReoprt.class)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<FailReoprt> getFails() {
		return fails;
	}

	@ManyToOne
	@JoinColumn(name="flowTaskId")
	public FlowTask getFlowTask() {
		return flowTask;
	}

	@ManyToOne
	@JoinColumn(name="preTaskId")
	public FlowTask getPreTask() {
		return preTask;
	}

	public void setPreTask(FlowTask preTask) {
		this.preTask = preTask;
	}

	public String getIcNo() {
		return icNo;
	}

	public Date getMacDate() {
		return macDate;
	}

	public String getMacNo() {
		return macNo;
	}

	@ManyToOne
	@JoinColumn(name="macUser")
	public User getMacUser() {
		return macUser;
	}
	
	@ManyToOne
	@JoinColumn(name="orderid")
	public OrderEntity getOrderEntity() {
		return orderEntity;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public String getPmonVersion() {
		return pmonVersion;
	}

	public String getProgramVersion() {
		return programVersion;
	}

	@OneToMany(mappedBy = "board", cascade = { CascadeType.REFRESH,CascadeType.REMOVE }, fetch = FetchType.LAZY, targetEntity = OperationRecord.class)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<OperationRecord> getRecords() {
		return records;
	}

	public String getRemark() {
		return remark;
	}

	@OneToMany(mappedBy = "board", cascade = { CascadeType.REFRESH,CascadeType.REMOVE }, fetch = FetchType.LAZY, targetEntity = RepairReport.class)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<RepairReport> getRepairs() {
		return repairs;
	}

	public String getStatus() {
		return status;
	}

	public String getSystemName() {
		return systemName;
	}

	public String getSystemVersion() {
		return systemVersion;
	}

	public void setFails(List<FailReoprt> fails) {
		this.fails = fails;
	}

	public void setFlowTask(FlowTask flowTask) {
		this.flowTask = flowTask;
	}

	public void setIcNo(String icNo) {
		this.icNo = icNo;
	}

	public void setMacDate(Date macDate) {
		this.macDate = macDate;
	}

	public void setMacNo(String macNo) {
		this.macNo = macNo;
	}

	public void setMacUser(User macUser) {
		this.macUser = macUser;
	}

	public void setOrderEntity(OrderEntity orderEntity) {
		this.orderEntity = orderEntity;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public void setPmonVersion(String pmonVersion) {
		this.pmonVersion = pmonVersion;
	}

	public void setProgramVersion(String programVersion) {
		this.programVersion = programVersion;
	}

	public void setRecords(List<OperationRecord> records) {
		this.records = records;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void setRepairs(List<RepairReport> repairs) {
		this.repairs = repairs;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}

	public void setSystemVersion(String systemVersion) {
		this.systemVersion = systemVersion;
	}
	
	
	
	
	
}
